<?php
require_once("gameObjects/storeHouse.php");
require_once("gameObjects/robotBase.php");
require_once("gameObjects/mainWeaponBase.php");
require_once("gameObjects/secWeaponBase.php");
require_once("gameObjects/robot.php");
require_once("gameObjects/mainWeapon.php");
require_once("gameObjects/secWeapon.php");
require_once("gameObjects/bullet.php");

class robotServer
{
	/**
	 * 玩家退出仓库时进行的仓库更新
	 *
	 * @param mixed $uid 玩家uid
	 * @param mixed $equipID 当前装备的机甲编号
	 * @param mixed $wepData_m 主武器的装备信息
	 * @param mixed $wepData_s 副武器的装备信息
	 */	
	public function updateRobots($uid,$equipID,$wepData_m,$wepData_s)
	{
		$sh = new storeHouse($uid); 
		$sh->equipRobot($equipID);
		$d = $sh->updateWeapon($wepData_m,$wepData_s);
		
		return 1;
	}
	/**
	 * 取得玩家拥有的机甲
	 *
	 * @param mixed $uid 玩家uid
	 */	
	public function getRobots($uid)
	{
		$sh = new storeHouse($uid);
		return $sh->getRobots();
	}
	/**
	 * 取得玩家拥有的主武器
	 *
	 * @param mixed $uid 玩家uid
	 */	
	public function getMainWeapons($uid)
	{
		$sh = new storeHouse($uid);
		return $sh->getMainWeapons();
	}
	/**
	* 取得玩家拥有的副武器
	*
	* @param mixed $uid 玩家uid
	*/	
	public function getSecWeapons($uid)
	{
		$sh = new storeHouse($uid);
		return $sh->getSecWeapons();
	}
	/////////////////////////////////////////////////
	/**
	 * 取得机甲的相关参数
	 *
	 * @param mixed $id 机甲id
	 * @param mixed $inc 强化等级
	 */	
	public function getRobotVals($id,$inc)
	{
		$part = new robotBase($id,$inc);
		$data =array("name"=>$part->name,"level"=>$part->level,"cost"=>$part->cost,"def"=>$part->def,"speed"=>$part->speed,"con_m"=>$part->con_m,"con_s"=>$part->con_s,"maxhp"=>$part->maxhp,"maxdur"=>$part->maxdur); 	
    		
    	return $data;
	}
	/**
	* 取得主武器的相关参数
	*
	* @param mixed $id 武器id
	* @param mixed $inc 强化等级
	*/	
	public function getMainWeaponVals($id,$inc)
	{
		$part = new mainWeaponBase($id,$inc);
		$data =array("name"=>$part->name,"level"=>$part->level,"cost"=>$part->cost,"bullet"=>$part->bullet,"maxbullets"=>$part->maxbullets,"reload"=>$part->reload,"pow"=>$part->pow,"speed"=>$part->speed,"maxdur"=>$part->maxdur); 	
    		
    	return $data;
	}
	/**
	* 取得副武器的相关参数
	*
	* @param mixed $id 武器id
	* @param mixed $inc 强化等级
	*/	
	public function getSecWeaponVals($id,$inc)
	{
		$part = new secWeaponBase($id,$inc);
		$data =array("name"=>$part->name,"level"=>$part->level,"cost"=>$part->cost,"bullet"=>$part->bullet,"pow"=>$part->pow,"speed"=>$part->speed,"maxdur"=>$part->maxdur); 	
		
    	return $data;
	}
	
	public function getBulletVals($id)
	{
		$bullet = new bullet($id);
		$data = array("mid"=>$bullet->mid,"type"=>$bullet->type,"speed"=>$bullet->speed,"range"=>$bullet->range);	
		
		return $data;
	}
	
	public function getCurrentEquip($uid)
	{
		$sh = new storeHouse($uid);
		return $sh->getCurrentEquip();	
	}
	
	public function getRobot($pid)
	{
		$robot = new robot($pid);
		return array("id"=>$robot->id,"hp"=>$robot->hp,"dur"=>$robot->dur,"def"=>$robot->baseValues->def,"speed"=>$robot->baseValues->speed,"maxhp"=>$robot->baseValues->maxhp,"maxdur"=>$robot->baseValues->maxdur,"radius"=>$robot->baseValues->radius);
	}
	
	public function getMainWeapon($pid)
	{
		$mainWeapon = new mainWeapon($pid);
		return array("pid"=>$mainWeapon->pid,"id"=>$mainWeapon->id,"dur"=>$mainWeapon->dur,"maxdur"=>$mainWeapon->baseValues->maxdur,"bullet"=>$mainWeapon->baseValues->bullet,"maxbullets"=>$mainWeapon->baseValues->maxbullets,"reload"=>$mainWeapon->baseValues->reload,"speed"=>$mainWeapon->baseValues->speed,"pow"=>$mainWeapon->baseValues->pow,);
	}
	
	public function getSecWeapon($pid)
	{
		$secWeapon = new secWeapon($pid);
		return array("pid"=>$secWeapon->pid,"id"=>$secWeapon->id,"dur"=>$secWeapon->dur,"maxdur"=>$secWeapon->baseValues->maxdur,"bullet"=>$secWeapon->baseValues->bullet,"speed"=>$secWeapon->baseValues->speed,"pow"=>$secWeapon->baseValues->pow);
	}
}
?>